home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / drcpas10.zip / ABSTOOLS.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-17  |  1KB  |  45 lines

  1. {$A+,B-,D-,F-,I+,L-,N-,O-,R-,S+,V-}
  2. Unit AbsTools;
  3.  
  4. (* by David R. Conrad, for Turbo Pascal 5.5
  5.  
  6.    This code is not copyrighted, you may use it freely.
  7.    There are no guarantees, either expressed or implied,
  8.    as to either merchantability or fitness for a particular
  9.    purpose.  The author's liability is limited to the amount
  10.    you paid for it.
  11.  
  12.    David R. Conrad, 17 Nov 92
  13.    David_Conrad@mts.cc.wayne.edu
  14.    dave@michigan.com
  15. *)
  16.  
  17. Interface
  18.  
  19. (* determine whether a disk is write-protected by first reading, then
  20.    writing the boot sector.  returns False if the read fails.
  21.    some monitoring programs may complain about the write of the boot
  22.    sector, so you may want to use another sector, but most monitoring
  23.    programs would also complain about the int 25h/26h access to the
  24.    disk anyway.
  25. *)
  26.  
  27. function WriteProtected (drive : byte) : boolean;
  28.  
  29. Implementation
  30.  
  31. Uses AbsIO;
  32.  
  33. var
  34.   sector : array[1..512] of byte;
  35.  
  36. function WriteProtected (drive : byte) : boolean;
  37. begin
  38.   AbsRead (drive, 0, 1, sector);
  39.   If AbsError <> 0 then begin WriteProtected := False; exit; end;
  40.   AbsWrite (drive, 0, 1, sector);
  41.   WriteProtected := AbsError <> 0;
  42. end;
  43.  
  44. End.
  45.